/**
 * $Id: CouseFactory.java,v 1.0 2022/6/3 23:02 shidesheng Exp $
 * <p>
 * Copyright 2021 Sinosoft Co.,Ltd. All rights reserved.
 */
package sds.mode.factory.simple;

/**
 * @author shidesheng
 * @version $Id: CouseFactory.java,v 1.1 2022/6/3 23:02 shidesheng Exp $
 * Created on 2022/6/3 23:02
 */
public class CourseFactory {

	ICourse create(Class<? extends ICourse> clazz){

		/* 基本实现
		if ("java".equals(name)){
			return new JavaCouse();
		}
		else if ("python".equals(name)){
			return new PythonCouse();
		}else
			return null;*/

		//  (ICouse)Class.forName(classNmae)反射实现
		/*if (!(className == null || "".equals(className))){
			try {
				return (ICouse) Class.forName(className).newInstance();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return null;*/

		// 通过 JavaCouse.class 反射实现
		// 优点不易出错
		if (clazz != null){
			try {
				return clazz.newInstance();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return null;
	}

}
